package com.ruoyi.project.business.controller;



import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PostMapping;

import org.springframework.web.bind.annotation.PutMapping;

import org.springframework.web.bind.annotation.DeleteMapping;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.framework.aspectj.lang.annotation.Log;

import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.project.business.domain.BusinessFarmService;

import com.ruoyi.project.business.service.IBusinessFarmServiceService;

import com.ruoyi.framework.web.controller.BaseController;

import com.ruoyi.framework.web.domain.AjaxResult;

import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.framework.web.page.TableDataInfo;



/**

 * 农田服务Controller

 * 

 * @author ruoyi

 * @date 2020-10-21

 */

@RestController

@RequestMapping("/business/farmService")

public class BusinessFarmServiceController extends BaseController

{

    @Autowired

    private IBusinessFarmServiceService businessFarmServiceService;



    /**

     * 查询农田服务列表

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:list')")

    @GetMapping("/list")

    public TableDataInfo list(BusinessFarmService businessFarmService)

    {

        startPage();

        List<BusinessFarmService> list = businessFarmServiceService.selectBusinessFarmServiceList(businessFarmService);

        return getDataTable(list);

    }



    /**

     * 导出农田服务列表

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:export')")

    @Log(title = "农田服务", businessType = BusinessType.EXPORT)

    @GetMapping("/export")

    public AjaxResult export(BusinessFarmService businessFarmService)

    {

        List<BusinessFarmService> list = businessFarmServiceService.selectBusinessFarmServiceList(businessFarmService);

        ExcelUtil<BusinessFarmService> util = new ExcelUtil<BusinessFarmService>(BusinessFarmService.class);

        return util.exportExcel(list, "farmService");

    }



    /**

     * 获取农田服务详细信息

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:query')")

    @GetMapping(value = "/{id}")

    public AjaxResult getInfo(@PathVariable("id") Long id)

    {

        return AjaxResult.success(businessFarmServiceService.selectBusinessFarmServiceById(id));

    }



    /**

     * 新增农田服务

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:add')")

    @Log(title = "农田服务", businessType = BusinessType.INSERT)

    @PostMapping

    public AjaxResult add(@RequestBody BusinessFarmService businessFarmService)

    {

        return toAjax(businessFarmServiceService.insertBusinessFarmService(businessFarmService));

    }



    /**

     * 修改农田服务

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:edit')")

    @Log(title = "农田服务", businessType = BusinessType.UPDATE)

    @PutMapping

    public AjaxResult edit(@RequestBody BusinessFarmService businessFarmService)

    {

        return toAjax(businessFarmServiceService.updateBusinessFarmService(businessFarmService));

    }



    /**

     * 删除农田服务

     */

    @PreAuthorize("@ss.hasPermi('business:farmService:remove')")

    @Log(title = "农田服务", businessType = BusinessType.DELETE)

	@DeleteMapping("/{ids}")

    public AjaxResult remove(@PathVariable Long[] ids)

    {

        return toAjax(businessFarmServiceService.deleteBusinessFarmServiceByIds(ids));

    }

}
